package org.nbict.iot.protocol;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Created by songseven on 18/6/17.
 */
public class Main {

    public static void main(String[] args) {

        //System.out.println(args.length);
//        System.out.println(args[0]);
//        System.out.println(args[1]);

//        LocalDateTime date = LocalDateTime.ofEpochSecond(1529627235, 0, ZoneOffset.of("+8"));
//        System.out.println(date);
//        byte[] patch = {0x23};
//        //byte checksum = (byte)23;
//        switch (patch[0]) {
//            case (byte)0x01: System.out.println(patch[0]);break;
//            case (byte)0x23: System.out.println(patch[0]);break;
//        }
//        Long a = new Long(1l);
//        Long b = new Long(2l);
//        System.out.println(a > b);
//        Pattern p = Pattern.compile("transit-.*-simple");
//        Matcher m = p.matcher("transit-5vvokv-simple");
//
//        System.out.println(m.matches());
//
//        String[] str = "raw-5vvokv-simple".split("-");
//        String a = StringUtils.replaceOnce("transit-5vvokv-simple", "transit", "raw");
//        System.out.println(a);

//        String topic = "5vvokv-simple";
//
//        String b = "transit-".concat(topic);
//        System.out.println(b);
//        System.out.println(m.matches());

//        int a = 0;
//        switch (a) {
//            case 0:;
//            case 1:
//                System.out.println("ok");
//            case 2:
//                System.out.println("hello");
//        }

//        KafkaSpoutConfig.FirstPollOffsetStrategy a = KafkaSpoutConfig.FirstPollOffsetStrategy.valueOf("UNCOMMITTED_LATEST");
//        System.out.println(a);

        Long runningDelay =  1l; //5分钟

        ScheduledExecutorService reducer = Executors.newScheduledThreadPool(1);
        ScheduledExecutorService dump = Executors.newScheduledThreadPool(1);
        reducer.scheduleWithFixedDelay(new Runnable() {
            private long count = 0;

            @Override
            public void run() {
                System.out.println("=> compress");
                if ((count++) % 12 == 0) {
                    System.out.println("=> dump");
                }
            }
        }, 1l, runningDelay, TimeUnit
                .SECONDS); //每隔10s执行一次

//
//        dump.scheduleAtFixedRate(new Runnable() {
//            @Override
//            public void run() {
//                System.out.println("***");
//            }
//        }, 15l, runningDelay, TimeUnit.SECONDS);
    }
}